#ifndef __BSP_GPIO_H
#define __BSP_GPIO_H	 

#include "stm32f10x.h"
#include "stdint.h"

#define VERSION   02

#if VERSION == 1
#define   RC_CLK       RCC_APB2Periph_GPIOB
#define   RC_PORT      GPIOB
#define   RC_PIN       GPIO_Pin_4


#define   AXIS_CLK      RCC_APB2Periph_GPIOB
#define   AXIS_PORT     GPIOB
#define   AXIS_PIN      GPIO_Pin_3


#define   CHARGE_CLK      RCC_APB2Periph_GPIOB
#define   CHARGE_PORT     GPIOB
#define   CHARGE_PIN      GPIO_Pin_5

#elif VERSION == 2

#define   RC_CLK       RCC_APB2Periph_GPIOB
#define   RC_PORT      GPIOB
#define   RC_PIN       GPIO_Pin_6

#define   AXIS_CLK      RCC_APB2Periph_GPIOB
#define   AXIS_PORT     GPIOB
#define   AXIS_PIN      GPIO_Pin_5

#define   CHARGE_CLK      RCC_APB2Periph_GPIOB
#define   CHARGE_PORT     GPIOB
#define   CHARGE_PIN      GPIO_Pin_7

#define   MQTT_CLK      RCC_APB2Periph_GPIOA
#define   MQTT_PORT     GPIOA
#define   MQTT_PIN      GPIO_Pin_6

#endif


#define   KEY_CLK        RCC_APB2Periph_GPIOB
#define   KEY_PORT       GPIOB

#define   KEY_PIN1       GPIO_Pin_14
#define   KEY_PIN2       GPIO_Pin_15

#define   KEY1           (!GPIO_ReadInputDataBit(KEY_PORT,KEY_PIN1))
#define   KEY2           (!GPIO_ReadInputDataBit(KEY_PORT,KEY_PIN2))


typedef struct
{
	GPIO_TypeDef* GPIOx;
	uint16_t      GPIO_Pin;
  uint8_t       Polarity;
}GPIO_OUT_t;


enum GPIO_OUT_MODE_E
{
	CLOSE = 0,
	OPEN,
	TOG,
};


enum GPIO_POLARITY_E
{
	NEG = 0,
	POS,
};

void GPIO_INIT(void);
void gpio_out(GPIO_OUT_t *out,uint8_t mode);

extern GPIO_OUT_t RC_Ctrl,AXIS_Ctrl,LED_Ctrl,CHARGE_Ctrl,Mqtt_Ctrl;

#endif




